package com.pignest.hotel.service;

import java.util.List;

import com.pignest.hotel.beans.TbGoods;
import com.pignest.hotel.util.WhereCreator;

public class GoodsService extends BaseService {

	public TbGoods getGoods(String id){
		
		return get(TbGoods.class,id);
	}
	public List<TbGoods> queryGoods(String hql,int start,int length){
		
		return this.queryPageHql(hql, start, length);
	}
	public String deleteGoods(String ids[])
	{
		
		if(ids==null)
			return "无效的ID";
		WhereCreator where = new WhereCreator();
		String id =where.getInstr(ids);
		String hql =" from TbLiveGoodsBorrow b where b.tbGoods.goodsId in("+id+")";
		List l =this.find(hql.toString());
		if(l!=null&&l.size()>0)
			return "在入住借用中有该记录不能删除！";
		for(int i=0;i<ids.length;i++){
			this.delete(TbGoods.class, ids[i]);
		}
		return null;
	}
}
